/**
 * Created by Eran on 2014/8/28.
 */
package
{

import starling.display.Image;
import starling.display.Sprite;
import starling.events.Event;
import starling.utils.AssetManager;

public class PerformanceTestScene extends Sprite
{
	private var mAssetManger:AssetManager;

	private var mAllTestImageVector:Vector.<Image>;

	public function PerformanceTestScene()
	{
		mAssetManger = new AssetManager();
		mAssetManger.enqueue("1.png", "2.png", "3.png", "4.png", "5.png", "6.png", "7.png", "8.png", "9.png", "10.png");
		mAssetManger.loadQueue(onAssetLoadingInProgress);
	}

	//============================================//
	//==Initialize&Dispose  Function
	//============================================//

	private function onAssetLoadingInProgress(ratio:Number):void
	{
		if (ratio >= 1.0)
		{
			initialize();
		}
	}

	private function initialize():void
	{
		mAllTestImageVector = new Vector.<Image>();
		for (var i:int = 0; i < 10; i++)
		{
			for (var j:int = 0; j < 10; j++)
			{
				var img:Image = new Image(mAssetManger.getTexture(String(j + 1)));
				mAllTestImageVector.push(img);
				this.addChild(img);
			}
		}
		this.addEventListener(Event.ENTER_FRAME, onTick);
	}

	//============================================//
	//==Public Interface  Function
	//============================================//

	//========================//
	//==Private  Function
	//=========================//

	private function onTick(e:Event):void
	{
		for (var i:int = 0; i < 100; i++)
		{
			var img:Image = mAllTestImageVector[i];
			img.x = Main.STAGE_SIZE_WIDTH * Math.random();
			img.y = Main.STAGE_SIZE_HEIGHT * Math.random();
		}
	}


}
}